<?php
	include 'author.php';
	$user   = $_GET["user"];

	// 나의 메시지 가져오기
	$query 	= "SELECT idx, message FROM app_sb_msg WHERE receiver='$user'";
	$result = mysql_query($query) or die(mysql_error());

	$output = "{\"mylist\":[";
	$len = 0;
	while($data = mysql_fetch_array($result))
	{
		$len++;
		$output .= "{\"index\":\"$data[0]\", \"msg\":\"$data[1]\"},";
	}
	if($len != 0)
	{
		$output = substr($output, 0, -1);
	}

	$output .= "]}";
	$output = rawurlencode(iconv("CP949", "UTF-8", $output));

	echo "$output";

	//한번 보낸 데이터는 모두 삭제
	$query = "DELETE FROM app_sb_msg WHERE receiver='$user'";
	$result = mysql_query($query) or die(mysql_error());

	mysql_close($dbConn);
?>